/*顶部下拉出现隐藏顶部*/
window.addEventListener("scroll", function () {
    let Top = this.document.querySelector('.bread').offsetTop
    if (document.documentElement.scrollTop > Top) {
        document.querySelector(".headerHidden").style.top = "0px";
        document.querySelector(".headerHidden").style.transition = 'all .3s'
    } else {
        document.querySelector(".headerHidden").style.top = "-80px";
    }
});
// tab栏切换功能
let paysTag = document.querySelectorAll(".payType .item:nth-child(2) a")
let pays = document.querySelectorAll(".payType .item:nth-child(3) a")
for (let i = 0; i < paysTag.length; i++) {
    paysTag[i].addEventListener('click', function () {
        for (let j = 0; j < paysTag.length; j++) {
            paysTag[j].classList.remove("active")
        }
        this.classList.add("active")
    })
}
for (let i = 0; i < pays.length; i++) {
    pays[i].addEventListener('click', function () {
        for (let j = 0; j < pays.length; j++) {
            pays[j].classList.remove("active")
        }
        this.classList.add("active")
    })
}
// 倒计时功能
let time = document.querySelector(".payInfo .two span")
let count = ((+new Date() + 1800000) - +new Date()) / 1000
let minute = parseInt(count % 3600 / 60)
minute = minute < 10 ? '0' + minute : minute
let second = parseInt(count % 60)
second = second < 10 ? '0' + second : second
time.innerHTML = `${minute}分${second}秒`
count--
function reverseCount() {
    let timer = setInterval(function () {
        minute = parseInt(count % 3600 / 60)
        minute = minute < 10 ? '0' + minute : minute
        second = parseInt(count % 60)
        second = second < 10 ? '0' + second : second
        time.innerHTML = `${minute}分${second}秒`
        count--
        if (count === 0) {
            clearInterval(timer)
        }
    }, 1000)
}
reverseCount()